﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Linq;

using ClassesTableAdapters;

public partial class MyClasses : System.Web.UI.Page
{
    public ILE_Global ileGlobal = new ILE_Global();

    MyClassesBLL myClassesLogic = new MyClassesBLL();
    ClassBLL classLogic = new ClassBLL();

    protected int UserID
    {
        get
        {
            if (Session["UserID"] != null)
            {
                return Convert.ToInt32(Session["UserID"]);
            }
            else
            {
                ileGlobal.RecordError("MyClasses.aspx", "UserID Empty", 2);
                return -1;
            }

        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        // *********** TEST ***********
        //Session["AccountType"] = "Instructor";
        //Session["UserID"] = "10";
        // ********* TEST END *********

        //if (User.Identity.IsAuthenticated == false)
        //{
        //    Response.Redirect("Login.aspx");
        //}

        //lblTemp.Text = Session["AccountType"].ToString();
        //lblTemp.Text = Session.Timeout.ToString();

        if (Page.IsPostBack == false)
        {
            // Anti SQL Injection Code is required here....
            string mode = String.Empty;
            string info = String.Empty;
            try
            {
                mode = Request.QueryString["mode"].ToString();
            }
            catch
            {
                mode = String.Empty;
            }
            try
            {
                info = Request.QueryString["info"].ToString();
            }
            catch  
            {
                info = String.Empty;
            }

            try
            {
                int tmp = Convert.ToInt32(Session["UserID"].ToString());
            }
            catch (Exception ex)
            {
                ileGlobal.RecordError("MyClasses.aspx.cs:Page_Load:001", ex, "User Session Ended Unexpectedly", 3);
                FormsAuthentication.SignOut();
                // *SteveMsg
                string _msg = "Your Session Information has ended. You have been logged out to prevent errors.";
                ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", _msg, 2, "../Default.aspx");
                return;
            }

            if (mode == "setup")
            {
                MultiViewMyClasses.ActiveViewIndex = 0;
                if (info == "1")
                {
                    UsersBLL usersLogic = new UsersBLL();
                    Users.UsersRow user = usersLogic.GetUserByUserID(UserID);

                    if (user.FirstName == "Private" && user.LastName == "Private")
                    {
                        txtFirstName.Visible = true;
                        txtLastName.Visible = true;
                        lblFirstName.Visible = false;
                        lblLastName.Visible = false;
                    }

                    lblFirstName.Text = user.FirstName;
                    lblLastName.Text = user.LastName;
                    txtEmail.Text = user.Email;
                    switch (user.Year)
                    {
                        case -1:
                            ddlistYear.SelectedIndex = 0;
                            break;
                        case 0:
                            ddlistYear.SelectedIndex = 6;
                            break;
                        case 1:
                            ddlistYear.SelectedIndex = 1;
                            break;
                        case 2:
                            ddlistYear.SelectedIndex = 2;
                            break;
                        case 3:
                            ddlistYear.SelectedIndex = 3;
                            break;
                        case 4:
                            ddlistYear.SelectedIndex = 4;
                            break;
                        case 5:
                            ddlistYear.SelectedIndex = 5;
                            break;
                        default:
                            ddlistYear.SelectedIndex = 0;
                            break;
                    }
                    WizardMyClassesSetup.ActiveStepIndex = 2;
                }
            }
            else
            {
                // Check if User has Setup My Class yet
                // If YES, redirect to My Class Page.
                // IF NO, redirect to My Class SETUP Page.
                MyClassesBLL myClassesLogic = new MyClassesBLL();

                UsersBLL usersLogic = new UsersBLL();
                Users.UsersRow user = usersLogic.GetUserByUserID(UserID);
                if (user.FirstName == "Private" && user.LastName == "Private")
                {
                    ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", "Our records for you are incomplete.<br />Please fill out the form and hit Next to continue.", 0, "MyClasses.aspx?mode=setup&info=1");
                    return;
                }

                if (myClassesLogic.IsSetup(UserID) != true)
                {
                    Response.Redirect("MyClasses.aspx?mode=setup");
                }

                MultiViewMyClasses.ActiveViewIndex = 1;

                Classes.MyClassesDataTable myClasses = myClassesLogic.GetMyClassesByUserID(UserID);
                rptrMyClassList.DataSource = myClasses.Rows;
                rptrMyClassList.DataBind();


                MaintenanceBLL maintenanceLogic = new MaintenanceBLL();
                if (maintenanceLogic.GetMaintenance("ClassPopup").IsEnabled)
                {
                    if (Session["ClassPopupSeen"] == null)
                    {
                        string _msg = maintenanceLogic.GetMaintenance("ClassPopup").Message;
                        ModalPopupMessage.ShowModalPopup("ILE Maintenance", _msg, 0);
                        Session["ClassPopupSeen"] = "Seen";
                    }
                }
            }
        }
    }

    protected void ddlistYear_SelecectedIndexChanged(object sender, EventArgs e)
    {
        int SelectedValue = Convert.ToInt32(((DropDownList)sender).SelectedValue);

        if (SelectedValue != -1)
        {
            UsersBLL usersLogic = new UsersBLL();
            Users.UsersRow user = usersLogic.GetUserByUserID(UserID);
            bool result = usersLogic.UpdateUserByUserID(user.Username, user.AccountType, user.FirstName, user.LastName, user.StudentIDNumber, user.Email, SelectedValue, user.IsEnabled, UserID);
            if (result)
            {
                //ModalPopupMessage.ShowModalPopup("ILE Message", "Thank you", 1);
            }
            else
            {
                ModalPopupMessage.ShowModalPopup("ILE Message", "Error has occurred. Please Try Again", 2);
            }
        }
    }

    protected void WizardMyClassesSetup_Finish(object sender, EventArgs e)
    {
        UsersBLL usersLogic = new UsersBLL();
        Users.UsersRow user = usersLogic.GetUserByUserID(UserID);

        if (user.FirstName == "Private" && user.LastName == "Private")
        {
            usersLogic.UpdateUserByUserID(user.Username, user.AccountType, txtFirstName.Text, txtLastName.Text,
                user.StudentIDNumber, user.Email, user.Year, user.IsEnabled, UserID);
        }

        Response.Redirect("MyClasses.aspx");
    }

    protected void FillDDListCourses()
    {
        ddlistCourses.Items.Clear();

        Classes.CoursesDataTable courseList = myClassesLogic.GetCoursesOrderByTitle(true); // GET ENABLED COURSES

        if (courseList == null)
        {
            ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", "We're Sorry. An error has occurred. Please try again.", 2, "MyClasses.aspx?mode=setup");
            return;
        }

        ListItem listItem = new ListItem();

        if (courseList.Count == 0)
        {
            listItem.Text = "--No Class Added--";
            listItem.Value = "0";
        }
        else
        {
            listItem.Text = "--Please Select a Class--";
            listItem.Value = "0";
        }
        listItem.Attributes.CssStyle.Add("font-style", "italic");

        ddlistCourses.Items.Add(listItem);

        foreach (Classes.CoursesRow course in courseList)
        {
            ListItem newListItem = new ListItem(course.Title.ToString(), course.CourseID.ToString());
            ddlistCourses.Items.Add(newListItem);
        }
    }

    protected void FillDDListSections()
    {
        ddlistSections.Items.Clear();

        int CourseID = Convert.ToInt32(ddlistCourses.SelectedValue);

        if (CourseID != 0)
        {
            Classes.Courses_SectionDataTable sectionList = classLogic.GetSectionsByCourseID(CourseID, true);

            if (sectionList == null)
            {
                ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", "We're Sorry. An error has occurred. Please try again.", 2, "MyClasses.aspx?mode=setup");
                return;
            }

            ListItem listItem = new ListItem();

            if (sectionList.Count == 0)
            {
                listItem.Text = "--No Section Available--";
                listItem.Value = "0";
            }
            else
            {
                listItem.Text = "--Section--";
                listItem.Value = "0";
            }

            listItem.Attributes.CssStyle.Add("font-style", "italic");

            ddlistSections.Items.Add(listItem);

            foreach (Classes.Courses_SectionRow section in sectionList)
            {
                string SectionNumberAndClassTime = String.Empty;
                if (section.ClassTime == String.Empty)
                {
                    SectionNumberAndClassTime = section.SectionNumber.ToString();
                }
                else
                {
                    SectionNumberAndClassTime = section.SectionNumber.ToString() + " (" + section.ClassTime.ToString() + ")";
                }
                if (section.IsEnabled == true)
                {
                    ListItem newListItem = new ListItem(SectionNumberAndClassTime, section.SectionNumber.ToString());
                    ddlistSections.Items.Add(newListItem);
                }
            }

            if (ddlistSections.SelectedValue != "0")
            {
                btnAddToMyClassList.Enabled = true;
            }
            else
            {
                btnAddToMyClassList.Enabled = false;
            }
        }
    }

    protected void ddlistCourses_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlistCourses.SelectedIndex != 0)
        {
            FillDDListSections();
            ddlistSections.Enabled = true;
        }
        else
        {
            ddlistSections.Enabled = false;
            btnAddToMyClassList.Enabled = false;
        }
    }

    protected void ddlistSections_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlistSections.SelectedIndex != 0)
        {
            try
            {
                string Course = ddlistCourses.SelectedValue.ToString();
                if (Course == String.Empty)
                {
                    Course = "0";
                }
                int CourseID = Convert.ToInt32(Course);

                string Section = ddlistSections.SelectedValue.ToString();
                if (Section == String.Empty || Section == "0")
                {
                    ModalPopupMessage.ShowModalPopup("ILE Message", "Please select a section.", 2);
                    return;
                }
                int SectionNumber = Convert.ToInt32(Section);
                int SortOrder = Convert.ToInt32(myClassesLogic.GetMyClassesByUserID(UserID).Count) + 1;

                bool IsDuplicated = myClassesLogic.IsDuplicated(CourseID, SectionNumber, UserID);
                if (IsDuplicated == true)
                {
                    lblMsgMyClassList.Text = "<span class='failedMessage'>" + ddlistCourses.SelectedItem.Text.ToString() + " Section " + ddlistSections.SelectedItem.Text.ToString()
                            + " is already on your My Class List!</span>";
                    GridViewMyClassList.DataBind();
                    DisplayNoClassText();
                }
                else
                {
                    bool result = myClassesLogic.InsertMyClass(CourseID, SectionNumber, UserID, "Student", SortOrder);
                    if (!result)
                    {
                        ileGlobal.RecordError("MyClasses.aspx.cs:ddlistSections_SelectedIndexChanged:002", "Failed to insert My Class", 4);
                    }

                    GridViewMyClassList.DataBind();
                    lblMsgMyClassList.Text = "<span class='successfulMessage'>" + ddlistCourses.SelectedItem.Text.ToString() + " Section " + ddlistSections.SelectedItem.Text.ToString()
                        + " has been added to your List!</span>";
                    DisplayNoClassText();
                }
            }
            catch (Exception ex)
            {
                ileGlobal.RecordError("MyClasses.aspx.cs:ddlistSections_SelectedIndexChanged:001", ex, 4);
                ModalPopupMessage.ShowModalPopup("ILE Message", "Error has occurred while processing. Please Try Again.", 2);
            }
        }
    }

    protected void btnAddToMyClassList_Click(object sender, EventArgs e)
    {
        //try
        //{
        //    string Course = ddlistCourses.SelectedValue.ToString();
        //    if (Course == String.Empty)
        //    {
        //        Course = "0";
        //    }
        //    int CourseID = Convert.ToInt32(Course);

        //    string Section = ddlistSections.SelectedValue.ToString();
        //    if (Section == String.Empty || Section == "0")
        //    {
        //        ModalPopupMessage.ShowModalPopup("ILE Message", "Please select a section.", 2);
        //        return;
        //    }
        //    int SectionNumber = Convert.ToInt32(Section);
        //    int SortOrder = Convert.ToInt32(myClassesLogic.GetMyClassesByUserID(UserID).Count) + 1;

        //    bool IsDuplicated = myClassesLogic.IsDuplicated(CourseID, SectionNumber, UserID);
        //    if (IsDuplicated == true)
        //    {
        //        lblMsgMyClassList.Text = "<span class='failedMessage'>" + ddlistCourses.SelectedItem.Text.ToString() + " Section " + ddlistSections.SelectedItem.Text.ToString()
        //                + " is already on your My Class List!</span>";
        //        GridViewMyClassList.DataBind();
        //        DisplayNoClassText();
        //    }
        //    else
        //    {
        //        bool result = myClassesLogic.InsertMyClass(CourseID, SectionNumber, UserID, "Student", SortOrder);
        //        if (!result)
        //        {
        //            ileGlobal.RecordError("MyClasses.aspx.cs:btnAddToMyClassList_Click:002", "Failed to insert My Class", 4);
        //        }

        //        GridViewMyClassList.DataBind();
        //        lblMsgMyClassList.Text = "<span class='successfulMessage'>" + ddlistCourses.SelectedItem.Text.ToString() + " Section " + ddlistSections.SelectedItem.Text.ToString()
        //            + " has been added to your List!</span>";
        //        DisplayNoClassText();
        //    }
        //}
        //catch (Exception ex)
        //{
        //    ileGlobal.RecordError("MyClasses.aspx.cs:btnAddToMyClassList_Click:001", ex, 4);
        //    ModalPopupMessage.ShowModalPopup("ILE Message", "Error has occurred while processing. Please Try Again.", 2);
        //}
    }

    protected void GridViewMyClassList_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        lblMsgMyClassList.Text = "<span class='successfulMessage'>Class has been deleted from your List!</span>";

        DisplayNoClassText();
    }

    protected void DisplayNoClassText()
    {
        //int UserID = Convert.ToInt32(Session["UserID"]);

        if (myClassesLogic.GetMyClassesByUserID(UserID).Count == 0)
        {
            lblNoClass.Text = "You have not set up your class yet. <br />Please add your class(es) using the dropdown list above.";
        }
        else
        {
            lblNoClass.Text = "";
        }
    }

    protected void WizardMyClassesSetup_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        UsersBLL usersLogic = new UsersBLL();
        Users.UsersRow user = usersLogic.GetUserByUserID(UserID);
        switch (e.CurrentStepIndex)
        {
            case 0:
                FillDDListCourses();
                FillDDListSections();

                DisplayNoClassText();
                break;
            case 1:
                MyClassesBLL myClassesLogic = new MyClassesBLL();

                if (myClassesLogic.IsSetup(UserID) != true)
                {
                    string _msg = "You must add at least 1 class to finish the setup.";
                    ModalPopupMessage.ShowModalPopup("ILE Message", _msg, 2);
                    e.Cancel = true;
                }
                else
                {
                    //if (ddlistSections.SelectedIndex != 0)
                    //{
                    //    try
                    //    {
                    //        string Course = ddlistCourses.SelectedValue.ToString();
                    //        if (Course == String.Empty)
                    //        {
                    //            Course = "0";
                    //        }
                    //        int CourseID = Convert.ToInt32(Course);

                    //        string Section = ddlistSections.SelectedValue.ToString();
                    //        if (Section == String.Empty || Section == "0")
                    //        {
                    //            ModalPopupMessage.ShowModalPopup("ILE Message", "Please select a section.", 2);
                    //            return;
                    //        }
                    //        int SectionNumber = Convert.ToInt32(Section);
                    //        int SortOrder = Convert.ToInt32(myClassesLogic.GetMyClassesByUserID(UserID).Count) + 1;

                    //        if (CourseID != 0 && SectionNumber != 0)
                    //        {
                    //            bool IsDuplicated = myClassesLogic.IsDuplicated(CourseID, SectionNumber, UserID);
                    //            if (IsDuplicated == false)
                    //            {
                    //                bool result = myClassesLogic.InsertMyClass(CourseID, SectionNumber, UserID, "Student", SortOrder);
                    //                if (!result)
                    //                {
                    //                    ileGlobal.RecordError("MyClasses.aspx.cs:btnAddToMyClassList_Click:002", "Failed to insert My Class", 4);
                    //                }
                    //                Classes.CoursesRow course = classLogic.GetCourse(CourseID);
                    //                GridViewMyClassList.DataBind();
                    //                DisplayNoClassText();
                    //                ModalPopupMessage.ShowModalPopup("ILE Message", "ILE has added " + course.Title + " Sect.#" + SectionNumber.ToString() + " to your My Class List.", 0);
                    //            }
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        ileGlobal.RecordError("MyClasses.aspx.cs:btnAddToMyClassList_Click:002", ex, 4);
                    //        ModalPopupMessage.ShowModalPopup("ILE Message", "Error has occurred while processing. Please Try Again.", 2);
                    //    }
                    //}
                    user = usersLogic.GetUserByUserID(UserID);
                    if (user == null)
                    {
                        ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", "We're Sorry. An error has occurred. Please try again.", 2, "MyClasses.aspx?mode=setup");
                        e.Cancel = true;
                        return;
                    }

                    if (user.FirstName == "Private" && user.LastName == "Private")
                    {
                        txtFirstName.Visible = true;
                        txtLastName.Visible = true;
                        lblFirstName.Visible = false;
                        lblLastName.Visible = false;

                        ModalPopupMessage.ShowModalPopup("ILE Message", "ILE could not retrieve your information automatically. Please provide your first and last name.", 2);
                    }

                    lblFirstName.Text = user.FirstName;
                    lblLastName.Text = user.LastName;
                    txtEmail.Text = user.Email;
                    switch (user.Year)
                    {
                        case -1:
                            ddlistYear.SelectedIndex = 0;
                            break;
                        case 0:
                            ddlistYear.SelectedIndex = 6;
                            break;
                        case 1:
                            ddlistYear.SelectedIndex = 1;
                            break;
                        case 2:
                            ddlistYear.SelectedIndex = 2;
                            break;
                        case 3:
                            ddlistYear.SelectedIndex = 3;
                            break;
                        case 4:
                            ddlistYear.SelectedIndex = 4;
                            break;
                        case 5:
                            ddlistYear.SelectedIndex = 5;
                            break;
                        default:
                            ddlistYear.SelectedIndex = 0;
                            break;
                    }
                }
                break;
            case 2:
                user = usersLogic.GetUserByUserID(UserID);
                if (txtFirstName.Visible == true)
                {
                    if (txtFirstName.Text == String.Empty || txtLastName.Text == String.Empty || txtEmail.Text == String.Empty)
                    {
                        ModalPopupMessage.ShowModalPopup("ILE Message", "Please provide your name and email address.", 2);
                        e.Cancel = true;
                        return;
                    }

                    bool result = usersLogic.UpdateUserByUserID(user.Username, user.AccountType, txtFirstName.Text, txtLastName.Text, user.StudentIDNumber, txtEmail.Text, user.Year, user.IsEnabled, UserID);
                    if (result)
                    {
                        ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", "Updated Your Information. Thank you!", 1, "MyClasses.aspx");
                    }
                }
                else if (txtEmail.Text != user.Email)
                {
                    bool result2 = usersLogic.UpdateUserByUserID(user.Username, user.AccountType, user.FirstName, user.LastName, user.StudentIDNumber, txtEmail.Text, user.Year, user.IsEnabled, UserID);
                    if (result2)
                    {
                        ModalPopupMessage.ShowModalPopup("ILE Message", "Updated Your Email Address. Thank you!", 1);
                    }
                }

                if (ddlistYear.SelectedIndex == 0)
                {
                    ModalPopupMessage.ShowModalPopup("ILE Message", "Please Select Your Year", 2);
                    e.Cancel = true;
                }
                break;
        }
    }

    protected void rptrMyClassList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Classes.MyClassesRow row = e.Item.DataItem as Classes.MyClassesRow;
            //LinkButton course = e.Item.FindControl("lnkbtnCourseTitle") as LinkButton;
            HyperLink course = e.Item.FindControl("lnkCourseTitle") as HyperLink;

            course.Text = row.Title.ToString();

            //Subtitle added to the Course Title
            //if (row.UseSectionInfo == false)
            //{
            //    course.Text += ": " + row.Subtitle;
            //}
            //else
            //{
            //    course.Text += ": " + row.SectionSubtitle;
            //}

            bool isEnabled = true;
            if (row.IsEnabled == false)
            {
                course.Enabled = isEnabled = false;
                course.ToolTip = "The course has been disabled.";
                course.Text += "&nbsp;&nbsp;<span style='font-size: smaller; color: #666;'>(Disabled)</span>";
            }
            else
            {
                if (row.UseSectionInfo == true && row.IsSectionEnabled == false)
                {
                    course.Enabled = isEnabled = false;
                    course.ToolTip = "The course has been disabled.";
                    course.Text += "&nbsp;&nbsp;<span style='font-size: smaller; color: #666;'>(Disabled)</span>";
                }
            }



            course.NavigateUrl = "Class.aspx?CourseID=" + row.CourseID.ToString() + "&SectionNumber=" + row.SectionNumber.ToString();

            Label section = e.Item.FindControl("lblSection") as Label;

            string SectionNumberAndClassTime = String.Empty;
            if (row.ClassTime == String.Empty)
            {
                SectionNumberAndClassTime = "<b>" + row.SectionNumber.ToString() + "</b>";
            }
            else
            {
                SectionNumberAndClassTime = "<b>" + row.SectionNumber.ToString() + "</b>&nbsp;&nbsp;&nbsp;<span style='font-size: 8pt;'>(" + row.ClassTime.ToString() + ")</span>";
            }

            section.Text = SectionNumberAndClassTime;


            LinkButton lnkbtnInstructor = e.Item.FindControl("lnkbtnInstructor") as LinkButton;
            UsersBLL usersLogic = new UsersBLL();
            Users._Relations_Course_UserRow userRelation = usersLogic.GetCourseUserRelationshipsByCourseIDAndSectionNumberAndUserID(row.CourseID, row.SectionNumber, UserID);
            if (userRelation.Type == "Instructor")
            {
                lnkbtnInstructor.PostBackUrl = "Instructor.aspx?CourseID=" + row.CourseID.ToString() + "&SectionNumber=" + row.SectionNumber.ToString();
                lnkbtnInstructor.Visible = true;
            }
            else
            {
                lnkbtnInstructor.Visible = false;
            }

            if (!isEnabled)
            {
                return;
            }

            AssignmentsBLL assignmentsLogic = new AssignmentsBLL();

            Label AssignmentLabel = e.Item.FindControl("lblAssignment") as Label;

            Assignments.RelationsDataTable relations = assignmentsLogic.GetRelationsByCourseIdAndSectionNumber(row.CourseID, row.SectionNumber);

            foreach (Assignments.RelationsRow relation in relations)
            {
                Assignments.AssignmentsRow assignment = assignmentsLogic.GetAssignmentByAssignmentID(relation.AssignmentID);

                if (DateTime.Now >= assignment.StartDateTime && DateTime.Now < assignment.EndDateTime)
                {
                    string timeLeft = String.Empty;
                    string btnColor = String.Empty;
                    double temp = assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes;
                    if (assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes > (60 * 24))
                    {
                        int Days = (Convert.ToInt32(assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes / 60 / 24));
                        timeLeft = Days.ToString() + " day(s)";
                        btnColor = "btnGreen.png";
                    }
                    else if (assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes < (60 * 24) &&
                             assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes > 60)
                    {
                        int Hours = (Convert.ToInt32(assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes / 60));
                        int Minutes = ((Convert.ToInt32(assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes)) % 60);
                        timeLeft = Hours.ToString() + " hour(s) " + Minutes.ToString() + " minute(s)";
                        btnColor = "btnYellow.png";
                    }
                    else if (assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes < 60)
                    {
                        int Minutes = ((Convert.ToInt32(assignment.EndDateTime.Subtract(DateTime.Now).TotalMinutes)) % 60);
                        timeLeft = Minutes.ToString() + " minute(s)";
                        btnColor = "btnRed.png";
                    }
                    StandardsBLL standardsLogic = new StandardsBLL();
                    AssignmentLabel.Text += "<div style='padding: 7px 0px 3px 0px;'><img src='Images/" + btnColor + "' alt='button' />&nbsp;<b>" + assignment.AssignmentTitle + "</b> is due within <b>" + timeLeft + "</b>.</div>";
                }
            }

            if (AssignmentLabel.Text == string.Empty)
            {
                AssignmentLabel.Text = "<span style='padding: 7px 0px 3px 0px;'><img src='Images/btnGrey.png' alt='btnGreen' />&nbsp;There are currently no assignments due for this class.</span>";
            }
        }
    }

}
